1. Field of the Invention
Embodiments of the present invention relate generally to methods of simulating dynamic objects. More particularly, embodiments of the present invention relate to methods of simulating dynamic objects using position based dynamics.
2. Description of Related Art
Contemporary video games tend to incorporate a variety of sophisticated effects designed to mimic the behavior of objects in the real world. These effects include, for example, simulated collisions, explosions, object deformations, and so on. One recent approach that game developers have used to generate these effects is to simulate the movement and interaction of objects using the laws of physics. For example, a video game may model objects such as fluids, clothing, people, and so on, as collections of vertices that are animated by applying forces such as gravity, pressure, friction, viscosity, surface tension, mass-spring forces, and impact, to each vertex. Computational simulations that rely on the laws of physics are referred to in this written description as “physics simulations.”
A virtual object that is susceptible to animation (e.g., movement or deformation) in a physics simulation is referred to in this written description as a “dynamic object.” A dynamic object is typically modeled as a collection of vertices, each having a position, a mass, and a velocity. In a physics simulation, the positions and velocities of the vertices are updated over time to simulate motion. In some cases, such as a clothing simulation, the vertices may be connected together, i.e. constrained by topological. In other cases, such as fluid simulations, each vertex may be unconnected from the other vertices.
A conventional method of performing a physics simulation on a dynamic object is shown, for example, in Figure (FIG.) 1. In this written description, exemplary method steps are denoted by parentheses (XXX). Referring to FIG. 1, the method comprises accumulating a plurality of forces at each vertex of a dynamic object (101). The method further comprises computing an acceleration for each vertex based the vertex's mass and the accumulated forces on the vertex (102). The acceleration is generally computed by Newton's second law of motion, which states that acceleration equals force divided by mass. The vertex's acceleration is then used to update the vertex's velocity (103), and finally, the vertex's new velocity is used to update its position (104). In general, steps (101) through (104) are carried out at predetermined timesteps throughout the simulation. As such, changes in a vertex's velocity and position are generally calculated by respectively integrating the vertex's acceleration and velocity over each timestep.
The method of FIG. 1 can use a variety of different numerical techniques to update the velocities and positions. For example, some common techniques include various forms of implicit or explicit integration, and finite element method or finite difference approaches.
One variation of the method illustrated in FIG. 1 uses impulses rather than forces to control vertex animation in the physics simulation. Because impulses directly impact velocities, using impulses allows velocities to be updated without performing an integration step on the accelerations. In other words, the impulses can be used instead of performing steps (101) and (102).
In designing and implementing physics simulations for video games, it is important to strike a balance between making the animations look as realistic as possible, and generating the animations fast enough to satisfy any real-time computational constraints of the games. For example, a physics simulation for an interactive video game must be fast enough and realistic enough that a user can engage in meaningful interactions the game's virtual environment without awkward delays or strange visual effects such as interpenetrating or unusually expanding or contracting objects.
In practice, it can be difficult to simultaneously achieve both the speed and realism required by physics simulations in interactive video games. For example, some techniques used to generate highly accurate physics simulations (e.g., techniques used in precision scientific applications such as molecular modeling or protein folding) are too slow for interactive video games. On the other hand, some techniques used to generate fast physics simulations rely on unstable explicit integration techniques that can lead to overshooting and energy gain problems.
As an alternative to conventional methods that use forces or impulses to update the vertex positions of dynamic objects, researchers have developed position based approaches based on position based dynamics. In position based approaches, vertex positions are directly manipulated instead of being updated by integration over a predetermined timestep. Typically, the velocity of each vertex is implicitly stored by current and previous (or current and next) positions of the vertex. Two conventional examples of how the vertex positions may be manipulated include (1) moving each vertex toward a predefined goal position defined by a rest state of the dynamic object, or (2) moving each vertex to a position that satisfies a predetermined positional constraint of the vertex.
One advantage of position based approaches to dynamic object simulation is that they allow increased control over explicit integration, which prevents vertex positions from being adversely affected by numerical instability of the integration. In addition, since the vertex positions are directly manipulated, the vertices can be easily attached to kinematic objects and they can be prevented from penetrating other objects. Finally, position based approaches tend to be easy to understand, to implement, and debug.